var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2BundleManager = require("BundleManager");
var $2DataManager = require("DataManager");
var $2FlbMathUtil = require("FlbMathUtil");
var $2UserDataManager = require("UserDataManager");
var $2Role1 = require("Role1");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var h;
(function (e) {
  e[e.norm = 0] = "norm";
  e[e.die = 1] = "die";
})(h || (h = {}));
var def_Jiangshibwz = /* */function (_cc$Component29) {
  babel_inherits(u, _cc$Component29);
  var _super33 = babel_createSuper(u);
  function u() {
    var _this72;
    babel_classCallCheck(this, u);
    _this72 = _super33.apply(this, arguments);
    _this72.player = null;
    _this72.dragon = null;
    _this72.speed = 100;
    _this72.dir = cc.v2();
    _this72.type = 0;
    _this72.hp_js = 0;
    _this72.hp_total = 0;
    _this72.atk = 0;
    _this72.gs = 0;
    _this72.cur_time = 0;
    _this72.total_time = 0;
    _this72.is_kenyao = false;
    _this72.index = 0;
    _this72.state = h.norm;
    return _this72;
  }
  babel_createClass(u, [{
    key: "onLoad",
    value: function onLoad() {
      this.hp_total = this.hp_js = $2UserDataManager.default.instance.bwzjsInfo[$2DataManager.default.instance.fd_num].hp;
      this.atk = $2UserDataManager.default.instance.bwzjsInfo[$2DataManager.default.instance.fd_num].atk;
      this.gs = $2UserDataManager.default.instance.bwzjsInfo[$2DataManager.default.instance.fd_num].gs;
      this.cur_time = this.total_time = this.gs;
      this.dragon = this.node.getComponent(sp.Skeleton);
      this.dragon.skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "zombie/1-13jiangshi/1-13jiangshi", sp.SkeletonData);
      this.setSkin();
      this.dir = cc.v2(-1, 0);
    }
  }, {
    key: "onCollisionEnter",
    value: function onCollisionEnter(e, t) {
      var _this73 = this;
      if (this.state != h.die && ("role1" == e.node.name && (this.node.getComponent(sp.Skeleton).setAnimation(0, "kenyao", true), this.speed = 0, this.is_kenyao = true, cc.find("hp", this.player).active = true), "qiang" == e.node.name)) {
        if (!this.speed) {
          return;
        }
        this.hp_js -= this.player.getComponent($2Role1.default).lunqiang_hurt;
        if (this.hp_js <= 0) {
          this.state = h.die;
          this.speed = 0;
          this.node.getComponent(sp.Skeleton).setAnimation(0, "die", false);
          this.node.getComponent(sp.Skeleton).setCompleteListener(function (e) {
            "die" == e.animation.name && _this73.node.removeFromParent();
          });
        }
      }
    }
  }, {
    key: "onCollisionExit",
    value: function onCollisionExit(e, t) {
      if (this.state != h.die && "role1" == e.node.name) {
        this.dragon.setAnimation(0, "zou", true);
        this.dragon.timeScale = 1;
        this.speed = 100;
        this.is_kenyao = false;
        cc.find("hp", this.player).active = false;
      }
    }
  }, {
    key: "setType",
    value: function setType(e) {
      this.speed = e;
    }
  }, {
    key: "setSkin",
    value: function setSkin() {
      this.index = $2FlbMathUtil.MathUtil.getRandomInt(1, 13);
      this.dragon.setSkin(this.index + "js");
      this.dragon.setAnimation(0, "zou", true);
      this.dragon.timeScale = 1;
    }
  }, {
    key: "update",
    value: function update(e) {
      if ($2DataManager.default.instance.is_over) {
        return;
      }
      if (this.is_kenyao) {
        this.cur_time += e;
        if (this.cur_time >= this.total_time) {
          this.player.getComponent($2Role1.default).setHp(this.node), this.cur_time = 0;
        }
      }
      var t = this.dir.x * this.speed * e;
      this.dir.y;
      this.speed;
      this.node.x += t;
      this.node.position.sub(this.node.parent.position).mag() > cc.winSize.width + cc.winSize.height + 1e3 && this.node.removeFromParent();
    }
  }]);
  return u;
}(cc.Component);
cc__decorate([ccp_property(cc.Node)], def_Jiangshibwz.prototype, "player", undefined);
def_Jiangshibwz = cc__decorate([ccp_ccclass], def_Jiangshibwz);
exports.default = def_Jiangshibwz;